 @include "readarff.awk"

 BEGIN {AfterAllRows="tar3"}

 function tar3(c,   goal, total,score,memo,lives,arity) {
     lives   = Lives   ? Lives   : 5
     arity   = Arity   ? Arity   : 5
     repeats = Repeats ? Repeats : 100
     goal = Goal ? Goal : majority(c)
     total = rows1(c,goal,score,memo)
     while(lives > 0) {
	 lives = lives - 1 + builds(c,repeats,arity,score,memo,rules,)         
 }
   function builds(c,n,arity,score,memo,rules0, rules1) {
     do {

	 n--
     }   while(n>0) 
 }  
   function rule1(arity,cdf,rules,r,     m,tag,tmp,tags) {
     m= round(rand() * arity) 
     while (m-- > 0) { 
         tag = pick(cdf)
	 split(tag,tmp,"=")
	 rules[r][tmp[1]][tmp[2]]
	 tags = (tags ? tags ","  tag : tag)
     }
     if (! (tag in old)) 
	 old[tag] = matches(rules[r])
 }
 function matrches(c,rule) {
     for(row in Has[c]) score += match(row,c,rule)
     return score
 }
 function match(row,c,rule)
     for(a in rule) 

     for(col in Name)
	 if for(col in Name)
	       if(col != K)
 function majority(c,    klass,tmp,out,max) {
     max = -1
     for(klass in Klass[c])
	 for(value in F[c,K,klass])
	     if ((tmp = F[c,K,klass][value]) > max) {
		 out = klass
		 max = tmp
	     }
     return out
 }

 ; score  = all attribute ranges by 
 function score0(c,goal,cdf,\
		 allOfUs,all,col,v,us,them,b,r,a) {
     allOfUs   = Fall[c,K,goal]
     all       = Fall[c,K,"_"]
     for(col in Name)
	 if (col != K) 
	     for(v in F[c,col,goal]) {
		 us   = F[c,col,goal][v]
		 them = F[c,col,"_" ][v] - us
		 b    = us/allOfUs
		 r    = them/(all - allOfUs)
		 a[col "=" v]   = b^2/(b+r)}
     a2cdf(scores,cdf)
 }

